Photo from Wikimedia Commons
Nature makes penicillin; I just found it…
— Alexander Fleming
According to the Observatory of Economic Complexity (OEC), in 2019 South Sudan imported $667M, making it the number 186 trade destination in the world. The most recent imports of South Sudan are led by Cars, Delivery Trucks, Packaged Medicaments, Other Edible Preparations, and Knit Men’s Coats. The most common import partners for South Sudan are United Arab Emirates, Kenya, China, Switzerland, and Netherlands.
Let’s use the treemap layout to take a closer look.
# Load data
df = read.csv("archetypes/south-sudan-imports/imports-2019/imports-hs6-2019.csv", header = TRUE, stringsAsFactors = TRUE) #
df
df_origins = read.csv("archetypes/south-sudan-imports/origins-2019/origins-2019.csv", header = TRUE, stringsAsFactors = TRUE) #
df_origins
df_origins_pm = read.csv("archetypes/south-sudan-imports/origins-2019/origins-of-packaged-medicaments-2019.csv", header = TRUE, stringsAsFactors = TRUE) #
df_origins_pm
df_wrangle <- df %>% select(Section, HS2, HS4, HS6, Trade.Value)
# df_wrangle
df_wrangle_pm <- filter(df_wrangle, HS4 == 'Packaged Medicaments')
df_wrangle_pm
df_origins_wrangle <- df_origins %>% select(Continent, Country, Trade.Value)
# df_origins_wrangle
df_origins_pm_wrangle <- df_origins_pm %>% select(Continent, Country, Trade.Value)
# df_origins_pm_wrangle
section_palette <- c(
'Animal Products' = '#a0d447',
'Vegetable Products' = '#ed40f2',
'Animal and Vegetable Bi-Products Foodstuffs' = '#02a347',
'Mineral Products' = '#aa7329',
'Chemical Products' = '#f4ce0f',
'Plastics and Rubbers' = "#ed40f2",
'Animal Hides' = '#ff73ff',
'Wood Products' = '#efdc81',
'Paper Goods' = '#9c9fb2',
'Textiles' = '#a53200',
'Footwear and Headwear' = '#2cba0f',
'Stone And Glass' = '#9e0071',
'Precious Metals' = '#f46d2a',
'Metals' = '#edb73e',
'Machines' = "#2e97ff",
'Transportation' = "#69c8ed",
'Instruments' = '#f2aa86',
'Weapons' = '#dd0e31',
'Miscellaneous' = '#6df2b0',
'Arts and Antiques' = '#9cf2cf'
)
# Layouts
# squarified" (the default), "scol", "srow" or "fixed"
v1 <- ggplot(df_wrangle, aes(area = Trade.Value, fill = Section, label = HS6, subgroup = Section)) +
geom_treemap() +
geom_treemap_subgroup_border(colour = "white") +
geom_treemap_subgroup_text(place = "centre", grow = T, alpha = 0.5, colour =
"black", fontface = "italic", min.size = 0) +
geom_treemap_text(colour = "white", place = "topleft", reflow = T) +
scale_fill_manual(values = section_palette) +
theme_minimal() +
theme(legend.position = "none")
girafe(ggobj = v1, width_svg = 1280/72, height_svg = 720/72,
options = list(opts_sizing(rescale = TRUE, width = 1.0))
)